package com.wanghe.leetcode.jianzhioffer;

import java.util.Arrays;

/**
 * 题目01.01 判定字符是否唯一
 * 题目链接: https://leetcode-cn.com/problems/is-unique-lcci/
 */
public class Problem0101 {

    public static void main(String[] args) {
        String s = "leceode";
        System.out.print(isUnique(s));
    }

    public static boolean isUnique(String str) {

        if (null == str || 0 == str.length()) {
            return false;
        }

        long len = str.length();
        String[] strArray = str.split("");
        Arrays.sort(strArray);

        for (int i = 0; i < len - 1;i++) {
            if (strArray[i].equals(strArray[i+1])) {
                return false;
            }
        }

        return true;
    }


}
